using System;
using System.Collections.Generic;
using UnityEngine;

public class SettingsUI : ScriptableObjectSingleton<SettingsUI>
{
	[Serializable]
	public class Setting
	{
		public string key;

		public string value;

		public string GetText()
		{
			return GGFormat.FormatText(value);
		}
	}

	[Serializable]
	public class LayeredSpriteColor
	{
		public Color colorBck = Color.white;

		public Color colorFront = Color.white;

		public string spriteName;
	}

	public List<Setting> settings = new List<Setting>();

	private Dictionary<string, Setting> settingsMap = new Dictionary<string, Setting>();

	public List<LayeredSpriteColor> colorsForPrizes = new List<LayeredSpriteColor>();

	public LayeredSpriteColor GetColorForPrize(int index)
	{
		if (colorsForPrizes.Count == 0)
		{
			return new LayeredSpriteColor();
		}
		return colorsForPrizes[Mathf.Clamp(index, 0, colorsForPrizes.Count - 1)];
	}

	protected override void Init()
	{
		base.Init();
	}

	public string GetString(string key)
	{
		if (settingsMap.ContainsKey(key))
		{
			return settingsMap[key].GetText();
		}
		Setting setting = null;
		foreach (Setting setting2 in settings)
		{
			if (setting2.key == key)
			{
				setting = setting2;
				break;
			}
		}
		if (setting == null)
		{
			return null;
		}
		settingsMap[key] = setting;
		return setting.GetText();
	}
}
